package com.lzh.others.basejava.Exception_12;

import cn.hutool.core.lang.Console;

/**
 * @author by lzh
 * @Classname FullConstructors
 * @Description 为异常类定义一个接收字符串参数的构造器
 * @Date 2022/6/27 23:36
 */
public class FullConstructors {
    public static void f() throws MyException {
        Console.log("Throwing MyException from f()");
        throw new MyException();
    }

    public static void g() throws MyException {
        Console.log("Throwing MyException from g()");
        throw new MyException("Originated in g()");
    }

    public static void main(String[] args) {
        try {
            f();
        } catch (MyException e) {
            e.printStackTrace();//标准错误流
            e.printStackTrace(System.out);
        }
        try {
            g();
        } catch (MyException e) {
            e.printStackTrace(System.out);
        }
    }
}

class MyException extends Exception {
    public MyException() {
    }

    public MyException(String msg) {
        super(msg);
    }
}